var mongoose = require('mongoose')

mongoose.connect('mongodb://localhost/blog', { useNewUrlParser: true, useUnifiedTopology: true })

var Scheam = mongoose.Schema

var userScheam = new Scheam({
    id:{
        type: String,
        required:true
    },
    email:{
        type:String,
        required:true
    },
    nickname: {
        type: String,
        required: true
    },
    password: {
        type: String,
        required: true
    },
    created_time: {
        type: Date,
        default: Date.now
    },
    last_modified_time: {
        type: Date,
        default: Date.now
    },
    avatar:{
        type:String,
        default: '/public/img/avator-default.png'
    },
    bio:{
        type: String,
        default: ''
    },
    gender:{
        type: Number,
        enum:[-1,0,1],
        default: -1
    },
    birthday:{
        type: Date
    },
    status:{
        type:Number,
        // 0 没有限制权限
        // 1 不能评论
        // 2 不能登录
        enum:[0,1,2],
        default: 0
    }
})

module.exports = mongoose.model('User', userScheam)
